<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'DNA库';
$this->registerJsFile("/js/xna.js", ['depends' => 'yii\web\JqueryAsset']);
$count = 0;
$type = ($type == 1) ? 'dna' : 'rna';
?>
<div class="sample-xna-index">

    <table class="table table-bordered">
        <thead>
            <tr class="title">
                <th>#</th>
                <th>编号</th>
                <th>冰箱</th>
                <th>盒名</th>
                <th>位置</th>
                <th>浓度(ng/uL)</th>
                <th>体积(uL)</th>
                <th>使用量(uL)</th>
                <th>使用目的</th>
                <th>使用人</th>
                <th>使用时间</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <?php foreach($dataProvider as $data) : ?>
            <tr class="xna-origin">
                <td><?= ++ $count ?></td>
                <td><?= $data->xna_id ?></td>
                <td><?= ($data->xna_type == 1) ? '-80°C' : '' ?></td>
                <td><?= $data->case ?></td>
                <td><?= 'A('.$data->case_a.', '.$data->case_b.')&nbsp;X('.$data->xna_x.', '.$data->xna_y.', '.$data->xna_z.')' ?></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td><?= $data->crt_name ?></td>
                <td><?= $data->crt_time ?></td>
                <td>
                    <a href="/xna/view?id=<?= $data->pk_id ?>">
                        <span class="glyphicon glyphicon-eye-open"></span>
                    </a>
                    <?php if (count($data->part) < 1) : ?>
                    <a href="/xna/create-m?from=<?= $data->xna_id ?>">
                        <span class="glyphicon glyphicon-plus"></span>
                    </a>
                    <?php endif; ?>
                </td>
            </tr>
            <?php if ($data->part != '') : ?>
            <tr class="xna-m">
                <td><i class="fa fa-sort-asc"></i></td>
                <td><?= $data->part->xna_id ?></td>
                <td <?= ($data->part->xna_fridge != 0) ? '' : 'colspan=3' ?>><?= ($data->part->xna_fridge != 0) ? Yii::$app->params[$type.'_fridge'][$data->part->xna_fridge] : '' ?></td>
                <?php if ($data->part->xna_fridge != 0) : ?>
                <td><?= $data->part->case ?></td>
                <td><?= 'A('.$data->part->case_a.', '.$data->part->case_b.')&nbsp;X('.$data->part->xna_x.', '.$data->part->xna_y.', '.$data->part->xna_z.')' ?></td>
                <?php endif ; ?>
                <td><?= $data->part->xna_density ?></td>
                <td><?= $data->part->xna_volumn_left ?></td>
                <td></td>
                <td></td>
                <td><?= $data->part->crt_name ?></td>
                <td><?= $data->part->crt_time ?></td>
                <td>
                    <?php if ($data->part->xna_volumn_left > 0) : ?>
                    <a href="/xna/update?id=<?= $data->part->pk_id ?>&type=xna&from=<?= $type ?>">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </a>
                    <a href="/xna/create-<?= $type ?>?from=<?= $data->part->from_id ?>">
                        <span class="glyphicon glyphicon-plus"></span>
                    </a>
                    <?php endif; ?>
                </td>
            </tr>
            <?php endif; ?>
        <?php endforeach; ?>
    </table>
</div>
